<?
IF ($_COOKIE['sombredestin']){
 $session_id=$session;
}


//**********************************************************************
    SWITCH ($mode) {
    case "logout" :
    {
          $ip = (getenv("HTTP_X_FORWARDED_FOR")? getenv("HTTP_X_FORWARDED_FOR"): getenv("REMOTE_ADDR"));
            $time=microtime();
            $creat_sess="$time"."$ip";
               $session_id = md5(uniqid($creat_sess));
               
            $tmp=0;
            $userniv=$tmp;
            $usergrade=$tmp;
            $username="Anonyme";
            $userid=$tmp;
            $_USER_ID=$tmp;
            $userperso=$tmp;
            $templates="templates/default/";
             $_PERSO_ID=$tmp;


            
            SESSION_REGISTER("username");
            SESSION_REGISTER("userid");
            SESSION_REGISTER("userniv");
            SESSION_REGISTER("usergrade");
            SESSION_REGISTER("userperso");
            SESSION_REGISTER("templates");
            SESSION_REGISTER("_USER_CADRE");
            SESSION_REGISTER("_USER_ID");
            SESSION_REGISTER("_PERSO_ID");
            SESSION_REGISTER("_PERSO_NAME");
             $_USER_OPTION_NBRSUJET=10;
            $_USER_OPTION_NBRPOST=20;
             SESSION_REGISTER("_USER_OPTION_NBRSUJET");     //Nbr de sujet par pages
            SESSION_REGISTER("_USER_OPTION_NBRPOST");     //Nbr de post par pages

                     ECHO"<script language=\"javascript\">
                    if (SombreDestin.closed){
   alert('NOk');
}else{
  alert('Ok');
}
                      </script>";
  $message="<p align=\"justify\"><font color=\"#000000\">
                    <div align=\"center\"><font color=\"#FFFF00\"><strong> <p align=\"center\"><b>Vous &ecirc;tes deconnecter</b><br>
        <b>Cliquer</b>
        <a href=\"accueil.php?$SID\" target=\"_self\"> ICI </a>
        <b> pour revenir a l'index.</b></p>";



           $p="message";



             BREAK;
    }

    DEFAULT :
         /*
         IF ((empty($SID) || ISSET($SID))){
            $ip = (getenv("HTTP_X_FORWARDED_FOR")? getenv("HTTP_X_FORWARDED_FOR"): getenv("REMOTE_ADDR"));
            $time=microtime();
            $creat_sess="$time"."$ip";

            $session_id = md5(uniqid($creat_sess));

             
            $userniv=0;
            $username="Anonyme";
            $userid=0;
            $usergrade=0;
            $userperso=0;
            $templates="templates/default/";
            $_USER_CADRE=0;
            $_USER_ID=0;
            $_USER_OPTION_NBRSUJET=10;
            $_USER_OPTION_NBRPOST=20;
            $_SESSION_VAR_PAGE=NULL;
     IF (isset($HTTP_COOKIE_VARS['sombredestin'])){
            $variable="$username/$userid/$userperso/$userlvl/$templates";
            SetCookie("sombredestin","$variable",time()+3600*24);
        }


             
            SESSION_REGISTER("usergrade");
            SESSION_REGISTER("userniv");
            SESSION_REGISTER("username");
            SESSION_REGISTER("userid");
            SESSION_REGISTER("templates");
            SESSION_REGISTER("userperso");
            SESSION_REGISTER("userrace");
            SESSION_REGISTER("_USER_CADRE");
            SESSION_REGISTER("_USER_ID");
             SESSION_REGISTER("_SESSION_VAR_PAGE");
            SESSION_REGISTER("_USER_OPTION_NBRSUJET");     //Nbr de sujet par pages
            SESSION_REGISTER("_USER_OPTION_NBRPOST");     //Nbr de post par pages

            $test_pass=1;//Pour savoir si on est deja venu ici.
       BREAK ;

         }

             */



}//fin du switch.
        /*

IF ($mode!='logout'){
IF (!$sombredestin){


//SetCookie("sombredestin","$variable",time()+3600*24,'/',".sombredestin.be");

//echo"pas de cookies";
            
}
ELSE{
$sombredestin=$_COOKIE['sombredestin'];
$var=EXPLODE("/",$sombredestin);

echo "cookies, ok.";
$username=$car[0];
$userid=$var[1];
$userperso=$var[2];
$userlvl=$var[3];
$templates="templates/default/";
}
}



          */
/*
$client_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : $REMOTE_ADDR );
$session_id = md5(uniqid($user_ip));
*/

   $templates="templates/default/";

?>
